package com.esreport.Utils;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * @author xuweiwei
 * @date 2018/12/25
 */
public class FileUtil {

    public static List<File> listFile(File dir){
        List<File> fileList = new ArrayList<File>();
        for(File f:dir.listFiles()){
            if(f.isFile()){
                fileList.add(f);
            }
        }
        return fileList;
    }

    public static List<File> recursiveFile(File dir){
        List<File> result = new ArrayList<File>();
        for(File f:dir.listFiles()){
            if(f.isFile()){
                result.add(f);
            }else if(f.isDirectory()){
                result.addAll(recursiveFile(f));
            }
        }
        return result;
    }

    public static void main(String[] args) {
        List<File> fileList = listFile(new File("f:/"));
        for(File f:fileList){
            System.out.println(f.getAbsolutePath());
        }
    }
}
